/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class TestDemo {
    public static void main(String[] args) {
        int[] arr = {16,16,16};
        System.out.println(numFriendRequests(arr));
    }

    public static int numFriendRequests(int[] ages) {
        int[] age = new int[121];
        int count = 0;
        for(int x : ages){
            age[x]++;
        }

        for(int i = 1 ; i < 121 ; i++){
            if(age[i] == 0){
                continue;
            }
            for(int j = 1 ; j < 121 ;j++){
                if(j <= 0.5*i + 7){
                    continue;
                }
                if(j > i){
                    continue;
                }
                if(j == i){
                    count += age[j] * (age[j] - 1);
                    continue;
                }
                count += age[i] * age[j];
            }
        }
        return count;
    }
}
